$def with (batch_result=None)
$# type: (BatchResult)
$var title: $_("Batch Imports")

<div id="contentHead">
 <h1>$_("New Batch Import")</h1>
</div>
<div id="contentBody" class="batchImport">
  $:macros.BatchImportNavigation()
    <p>$_('Attach a JSONL formatted document with import records or copy/paste the JSONL text into the textarea.')</p>
    <p>$:_('See the <a href=\"https://github.com/internetarchive/openlibrary-client/tree/master/olclient/schemata\">olclient import schemata</a> for more.')</p>
    <form method="POST" enctype="multipart/form-data" action="">
      <p>$_('Attach a file:')</p>
      <input type="file" name="batchImportFile">
      <hr/>
      <p>$_('Or copy/paste JSONL text:')</p>
      <textarea name="batchImportText" rows="10" cols="70"></textarea>
      <hr/>
      <button type="submit">$_('Import')</button>
    </form>

    $if batch_result and batch_result.errors:
      <p>$_('Import failed.')</p>
      <p>$_('No import will be queued until *every* record validates successfully.')</p>
      <p>$_('Please update the JSONL file and reload this page (there should be no need to reattach the file).')</p>
      <p>$_('Validation errors:')</p>
      $for error in batch_result.errors:
        <li><strong>$_('Line %d:', error.line_number)</strong> $error.error_message</li>

    $if batch_result and batch_result.batch:
      <p>$_('Import results for batch:') Batch #$batch_result.batch.id ($batch_result.batch.name)</p>
      <p>$_('Records submitted:') $batch_result.batch.total_submitted</p>
      <p>$_('Total queued:') $batch_result.batch.total_queued</p>
      <p>$_('Total skipped:') $batch_result.batch.total_skipped</p>
      $if batch_result.batch.total_skipped > 0:
        <details>
          <summary>$_('Not queued because they are already present in the queue:')</summary>
          <ol>
            $for item in batch_result.batch.items_skipped:
              <li>$item</li>
          </ol>
        </details>
      <p><a href="/import/batch/$batch_result.batch.id">$_('View Batch Status')</a></p>
  </div>
</div>
